<template>
    <div>
        <div class="header-container">
            <div class="l-content">
                <el-button style="margin-right: 20px;" @click="handleMenu" icon="el-icon-menu" size="mini"></el-button>
                <el-breadcrumb separator="/">
                    <el-breadcrumb-item v-for="item in tags" :key="item.path" :to="{ path: item.path}">{{item.label}}</el-breadcrumb-item>
                </el-breadcrumb>
            </div>
            <div class="r-content">
                <el-dropdown  @command="handleClick">
                    <span class="el-dropdown-link">
                        <img class="user" src="../assets/images/生成圆形头像.png" alt="">
                    </span>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item>个人中心</el-dropdown-item>
                        <el-dropdown-item command="cancel">退出</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
            </div>
        </div>

    </div>
</template>
<script>
import { mapState } from 'vuex'
import Cookies from 'js-cookie'
export default {
    data() {
        return {}
    },
    methods: {
        handleMenu() {
            this.$store.commit('collapseMenu')
        },
        handleClick(command){
           if(command==='cancel'){
             // 清除cookie
            Cookies.remove('token')
            // 清除cookie中的menu
            Cookies.remove('menu')
            this.$router.push('login')

           }
        }
    },
    computed:{
        //扩展运算
        ...mapState({
            tags:state=>state.tab.tabsList
        })
    },
    mounted(){
        console.log(this.tags)
    }
}

</script>
<style lang="less" scoped>
.header-container {
    padding: 0 20px;
    background-color: #333;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .text {
        color: white;
        font-size: 14px;
        margin-left: 10px;
    }

    .r-content {
        .user {
            width: 40px;
            height: 40px;
            border-radius: 50%;
        }
    }
    
    .l-content {
        display: flex;
        align-items: center;
        
        // 样式穿刺
        /deep/ .el-breadcrumb_item {
            .el-breadcrumb_inner {
                font-weight: normal;
                &.is-link {
                    color: #666;
                }
            }
            
            &:last-child { // 修正拼写错误
                .el-breadcrumb_inner {
                    color: #fff;
                }
            }
        }
    }
}
</style>